package com.example.common.api;

public class ApiResponse<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> ApiResponse<T> ok(T data) {
        ApiResponse<T> r = new ApiResponse<>();
        r.code = 0; r.msg = "ok"; r.data = data;
        return r;
    }
    public static <T> ApiResponse<T> error(String msg) {
        ApiResponse<T> r = new ApiResponse<>();
        r.code = -1; r.msg = msg; r.data = null;
        return r;
    }
    public int getCode() { return code; }
    public String getMsg() { return msg; }
    public T getData() { return data; }
    public void setCode(int code) { this.code = code; }
    public void setMsg(String msg) { this.msg = msg; }
    public void setData(T data) { this.data = data; }
}
